<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.lmpop.trade.ti_goods.*" %>
<%@page import="com.lmpop.trade.shopcart.*"%>
<%@page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<%@page import="com.lmpop.trade.ts_category.*" %>
<%@page import="com.lmpop.trade.ts_categoryattr.*" %>
<%@page import="com.lmpop.createIndex.search.*" %>

<%
 
   request.setCharacterEncoding("utf-8");
   
   String goods_id="",goods_props="",goods_id_tem="",cust_id="";
	
   if(request.getParameter("goods_id") != null){
		   goods_id_tem = request.getParameter("goods_id").trim();
		   goods_id = goods_id_tem.split("\\/")[0];
		   
	}
	if(request.getParameter("goods_props") != null){
		   goods_props = request.getParameter("goods_props").trim();
	}
	if(request.getParameter("cust_id") != null){
		   cust_id = request.getParameter("cust_id").trim();
	}
	goods_props = new String(goods_props.getBytes("iso8859-1"),"utf-8");
//out.print(goods_props);
	CategoryattrIndexFiles attrIndex = new CategoryattrIndexFiles();
    GoodsIndexFiles goodsIndex = new GoodsIndexFiles();
	Map ginfoMap = goodsIndex.getOneGoods(goods_id);
   System.out.println("---------->"+goods_id+"------------->"+ginfoMap);
//out.print("goods_id========"+goods_id);
   %>     
<html>

    <head>
        <meta http-equiv="x-ua-compatible" content="ie=7" />
        <title>修改商品属性</title>
         <link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
		 <script type="text/javascript" src="/templets/html/js/jquery-1.4.2.min.js"></script>
		
		 <script type="text/javascript" src="/templets/html/js/thickbox/thickbox.js"></script>
		<link rel="stylesheet" href="/templets/html/js/thickbox/thickbox.css" type="text/css" media="screen" />
		 <script type="text/javascript" src="/templets/html/js/ShopCart.js"></script>
         <script type="text/javascript">
			$(function(){
				var goods_props = "<%=goods_props%>";
				
				if(goods_props.length >0){
					//goods_props =  goods_props.substring(0,goods_props.length-2);
					//alert(goods_props);	
					var props = goods_props.split(",");
					//alert(props.length);
					for(var i = 0 ;i<props.length;i++){
						//alert(i+"        "+props[i]);
						if(props[i].length>0){
							var prop = props[i].split("|");
							//alert(prop[1]);
							if(prop.length>0){
								$(".attrvalue"+i).each(function(index){
									//alert($(this).attr("id"));
									//alert(prop[1]);
									if($(this).attr("id")==prop[1]){
										//alert($(this).attr("id"));
										$(this).attr("checked","checked");
									}
								});
							}
						}
						
						//alert(prop[1]);
					}
				}
				$("#sure").click(function(){
					//alert("ok");
					var attr = "";
					var props = goods_props.split(",");
					
						for(var i = 0 ;i<props.length;i++){						
							if(props[i].length>0){
							$(".attrvalue"+i).each(function(index){									
									if($(this).attr("checked")){
										attr+=$(this).val();
									}
								});
							
							}
					}
					//alert(attr);
					self.parent.tb_remove();
					self.parent.window.location.href='/templets/html/b2c/jsp/shopingServices.jsp?cust_id=<%=cust_id%>'+'&goods_props='+attr+'&goods_id=<%=goods_id_tem%>'+'&type=0'+'&operatecode=5';
					//self.parent.window.location.href = '/index.html';
					//alert(self.parent.window.location);
				});
			})
		</script> 
		</head>

    <body>
    
			<div style="width:100%;">
		   <table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
				
				<tr>
			    <td>
        	<%
             String class_attr="";
             if(ginfoMap.get("class_attr")!=null)
             {
                class_attr = ginfoMap.get("class_attr").toString();             
             }
             String catAttr[] = class_attr.split("\\|");
             List attList = new ArrayList();
		     if(catAttr.length > 0 && !catAttr[catAttr.length-1].equals("")){
				attList = attrIndex.getCategoryAttrListByCatId(catAttr[catAttr.length-1]);
		     }
	//out.print(attList);				   
					   
				   List attrValueList = new ArrayList();
				   int attrsize = 0,thisnum=0;
    			   if( attList != null && attList.size() > 0 ){
						 attrsize = attList.size();
						 Hashtable attrmap = new Hashtable();
						System.out.println("---------->"+goods_id+"------------->"+attrmap);
					 	 for( int i = 0; i < attrsize; i++ )
						 {
						 	 attrmap = ( Hashtable )attList.get(i);
							 String attr_id = "",attr_name = "",default_tag ="", con_type="",attrStr = "",isfill="",default_value="";
							 if( attrmap.get("attr_id") != null )
							 {
							 	 attr_id = attrmap.get( "attr_id" ).toString();
							 }
							 if( attrmap.get("attr_name") != null )
							 {
							 	 attr_name = attrmap.get( "attr_name" ).toString();
							 }
							 if( attrmap.get("default_tag") != null )  // if fill in or not									 
							 {
							 	 default_tag = attrmap.get("default_tag" ).toString();
							 }
							 if( attrmap.get("con_type") != null )
							 {
							 	 con_type = attrmap.get("con_type").toString();
							 }
							 if( attrmap.get("default_value") != null )
							 {
							 	 default_value = attrmap.get("default_value").toString();
							 }
							 if( default_tag.equals( "0" ))
							 {
							 	 isfill = " <span style='color:red;'>*</span>";
							 }
							 String radioValue[] = default_value.split("\\|");
							 //if(!con_type.equals("2")) continue;
							 
						%>
						
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="18%" height="35" align="right" style="background:#F9F9F9;">
			          			&nbsp;<%=attr_name%><%=isfill%>
							</td>
			          
							<td width="48%" style="background:#F9F9F9;">
			          	
			          		<%
									if( con_type.equals( "0") ){
										thisnum ++ ;
							%>	
									  
									 <%
										if(radioValue.length > 0){
											for(int j=0;j<radioValue.length;j++){
												if(!radioValue[j].equals("")){
									%>
									
<input type="radio" name="attrvalue<%=i%>" class="attrvalue<%=i%>"  id="<%=radioValue[j]%>"
value="<%=attr_id%>|<%=radioValue[j]%>,"> 
<%=radioValue[j]%>

									<%
												}
											}
										}
									 %>
							<%			


									}
									
							%>
							</td>
			         	</tr>
			      </table>
			      <%		}
			      		}
						%>
						   	        	
        
        </td>        
        
        </tr>				
				
			</table> 
			</div>
			<br/>
			
			
			<div style="text-align:center;">
			<input type="button" class="buttoncss" value="确定" id="sure">
			
	 </div> 
	
    </body>
</html>
